var http = require("http.js");
  function getBookListByCategory(category) {
    return http.get("/books",{
      category:category
    },false)
 }
 

function getBookById(id) {
  return http.get("/books/"+id,{},false);
}
function getChaptersByBookId(book_id) {
  return http.get("/books/"+book_id+"/user_chapters",{},true);
}
/*
  获取指定章节的内容
*/
function getChapterContent(book_id,chapter_id) {
    return http.get("/books/"+book_id+"/chapters/"+chapter_id,{},true);
}
function buyChapter(book_id,chapter_id) {
  return http.post("/books/"+book_id+"/chapters/"+chapter_id,{},true);
}
function getBuyRecords() {
  return http.get("/books/buy_records",{},true);
}
//  获取书本合集，如热门，新书
function getBookListByCollection(name) {
  return http.get("/collection",{name:name});
}
 exports.getBookListByCategory = getBookListByCategory;
exports.getBookListByCollection = getBookListByCollection;
 exports.getBookById = getBookById;
 exports.getChaptersByBookId = getChaptersByBookId;
 exports.getChapterContent = getChapterContent;
 exports.buyChapter = buyChapter;
 exports.getBuyRecords = getBuyRecords;
 
 